<?php

function get_option($key)
{
    if (!is_string($key) || empty($key)) {
        return false;
    }

    $option_value = \Cache::remember($key, 1400, function () use ($key) {
        $value = App\Models\Option::where('key', $key)->value('value');
        if ($value) {
            return json_decode($value, true);
        } else {
            return false;
        }
    });
    return $option_value;

}

function set_option_cache($key)
{
    if (!is_string($key) || empty($key)) {
        return false;
    }

    $value = App\Models\Option::where('key', $key)->value('value');
    $value = json_decode($value, true);
    Cache::put($key, $value, 1400);
}

function get_withdraw_option()
{
    $array = get_option(config('set.withdraw'));
    if ($array === false) {
        $array = ['min' => 1000, 'withdraw_time' => 2];
    }
    return $array;

}

function getorderSN()
{
    $order_id_main = 'SN'.date('YmdHis') . rand(10000000,99999999);
    return $order_id_main;
}

function getrefundSN()
{
    $order_id_main = 'REF'.date('YmdHis') . rand(10000000,99999999);
    return $order_id_main;
}
